package EventManager;

import java.util.Date;

import Driver.Facade;
import Model.Event;
import Model.EventSpecification;
import Model.EventStatus;
import Model.VenueTimeslot;

/**
 * Administrator-level request that creates an event.
 * 
 * @author Yury Kitaev
 *
 */
public class CreateEventAdminRequest extends AdminRequest
{
	private Date date; // date and time
	private int duration; // in minutes
	private int capacity; // in persons
	private String title; 
	private VenueTimeslot venue;
	
	/**
	 * Constructor, similar to that of Event class
	 * @param title
	 * @param date
	 * @param duration
	 * @param capacity
	 * @param venue
	 * @param issuer
	 */
	public CreateEventAdminRequest(String title, Date date, int duration, int capacity, VenueTimeslot venue, Administrator issuer) 
	{
		super(issuer);
		this.date = date;
		this.duration = duration;
		this.capacity = capacity;
		this.title = title;
		this.venue = venue;
	}

	public Date getDate() 
	{
		return date;
	}

	public void setDate(Date date) 
	{
		this.date = date;
	}


	public int getDuration() 
	{
		return duration;
	}


	public void setDuration(int duration) 
	{
		this.duration = duration;
	}


	public int getCapacity() 
	{
		return capacity;
	}


	public void setCapacity(int capacity) 
	{
		this.capacity = capacity;
	}


	public String getTitle() 
	{
		return title;
	}


	public void setTitle(String title) 
	{
		this.title = title;
	}


	public VenueTimeslot getVenue() 
	{
		return venue;
	}


	public void setVenue(VenueTimeslot venue) 
	{
		this.venue = venue;
	}

	@Override
	public void process(Administrator issuer) 
	{
		try
		{
			super.process(issuer);
			setIssuer(issuer);
			EventSpecification spec  = new EventSpecification(title, true);
			Event e = new Event(date, duration, capacity, spec, EventStatus.Open, venue );
			Facade.getCatalog().getEvents().add(e);
			setStatus(RequestStatus.Sustained);
		}
		catch (Exception e)
		{
			setStatus(RequestStatus.Refused);
		}
	}
}
